package com.siwei.mes.service.laboratory.impl;


import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.DateHelper;
import com.siwei.mes.common.util.JsonUtils;
import com.siwei.mes.common.util.NullUtils;
import com.siwei.mes.common.util.UploadFlagUtils;
import com.siwei.mes.entity.ShxhSynchronizedata;
import com.siwei.mes.entity.UploadLaboratoryEntity;
import com.siwei.mes.entity.experiment.CheckBatchConfig;
import com.siwei.mes.entity.experiment.Experiment;
import com.siwei.mes.entity.experiment.ExperimentDetail;
import com.siwei.mes.entity.experiment.cement.CementAdx;
import com.siwei.mes.entity.experiment.cement.CementBzcd;
import com.siwei.mes.entity.experiment.cement.CementNjsj;
import com.siwei.mes.entity.experiment.cement.CementQdcd;
import com.siwei.mes.entity.experiment.concrete.batch.ConcreteKsdj;
import com.siwei.mes.entity.experiment.concrete.batch.ConcreteKyqd;
import com.siwei.mes.entity.experiment.concrete.batch.ConcreteKzqd;
import com.siwei.mes.entity.laboratory.ImportList;
import com.siwei.mes.entity.laboratory.PrintExamRecord;
import com.siwei.mes.entity.laboratory.PrintReport;
import com.siwei.mes.entity.laboratory.PrintReportSerialNumber;
import com.siwei.mes.entity.system.TestProjectSpecConfig;
import com.siwei.mes.enums.*;
import com.siwei.mes.enums.laboratory.ReportIdEnum;
import com.siwei.mes.mapper.ShxhSynchronizedataMapper;
import com.siwei.mes.mapper.experiment.CheckBatchConfigMapper;
import com.siwei.mes.mapper.experiment.ExperimentDetailMapper;
import com.siwei.mes.mapper.experiment.ExperimentMapper;
import com.siwei.mes.mapper.laboratory.ImportListMapper;
import com.siwei.mes.mapper.laboratory.PrintReportMapper;
import com.siwei.mes.mapper.laboratory.WTConsignMapper;
import com.siwei.mes.mapper.laboratory.WTSampleMapper;
import com.siwei.mes.mapper.system.TestProjectSpecConfigMapper;
import com.siwei.mes.service.laboratory.DownloadLaboratoryService;
import com.siwei.mes.service.laboratory.FinishLaboratoryService;
import com.siwei.mes.service.laboratory.factory.concrete.ConcreteLaboratoryFactoryService;
import com.siwei.mes.service.laboratory.factory.material.MaterialLaboratoryFactoryService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

import static com.siwei.mes.common.exception.handler.MessageHandler.assertTrue;

@Service
public class FinishLaboratoryServiceImpl implements FinishLaboratoryService {
    private static final Logger log = LoggerFactory.getLogger("laboratory");
    @Resource
    private ExperimentMapper experimentMapper;
    @Resource
    private ExperimentDetailMapper experimentDetailMapper;
    @Resource
    private ShxhSynchronizedataMapper shxhSynchronizedataMapper;
    @Resource
    private CheckBatchConfigMapper checkBatchConfigMapper;
    @Resource
    private WTSampleMapper wtSampleMapper;
    @Resource
    private ImportListMapper importListMapper;
    @Resource
    private WTConsignMapper wtConsignMapper;
    @Resource
    private PrintReportMapper printReportMapper;
    @Resource
    private DownloadLaboratoryService downloadLaboratory;
    @Resource
    private TestProjectSpecConfigMapper testProjectSpecConfigMapper;
    @Resource
    private ConcreteLaboratoryFactoryService concreteLaboratoryFactoryService;
    @Resource
    private MaterialLaboratoryFactoryService materialLaboratoryFactoryService;

    @Override
    public void finishLaboratory(UploadLaboratoryEntity entity) {
        try {
            assertTrue(entity == null || entity.getExperimentId() == null || entity.getExperimentId().isEmpty(), "上传上海协会数据，试验台账id不允许为空！");

            //需要同步的试验台账数据 id
            List<String> experimentId = entity.getExperimentId();

            for (String val : experimentId) {
                //查询品控台账信息
                Experiment experiment = experimentMapper.findExperimentById(Long.parseLong(val));

                //判断序号表是新增还是修改
                boolean isUpdateSn = false;
                PrintReportSerialNumber printReportSerialNumber = new PrintReportSerialNumber();

                PrintReport report = new PrintReport();
                //根据台账 查询品控做的试验项目详情 结果
                List<ExperimentDetail> experimentDetailList = experimentDetailMapper.getList(new ExperimentDetail().setExperimentId(experiment.getId()));

                JSONArray objArray = new JSONArray();
                for (ExperimentDetail experimentDetail : experimentDetailList) {
                    objArray.add(experimentDetail.getObjJson());
                }
                Date jcrq = ExperimentDetail.extractEndDate(objArray);
                String sampleNo;
                //过滤快检业务
                if (experiment.getCheckType() == null || experiment.getCheckType().equals(CheckEnum.QUICK.getCode())) {
                    log.error("不允许同步快检业务... 台账id：" + experiment.getId());
                    throw new RuntimeException("不允许同步快检业务... 台账id：" + experiment.getId());
                }

                //上传试验数据到协会软件
                //混凝土
                if (MaterialsEnum.CONCRETE.getCode().equals(experiment.getExperimentType())) {

                    List<ShxhSynchronizedata> list = shxhSynchronizedataMapper.getList(new ShxhSynchronizedata().setExperimentId(experiment.getId()));
                    if (list.isEmpty() || StringUtils.isBlank(list.get(0).getSampleId())) {
                        log.info("同步协会生成生产任务可能未成功！... 台账id：" + experiment.getId());
                        return;
                    }

                    //查询协会混凝土同步数据
                    ShxhSynchronizedata synchronizedata = list.get(0);

                    //上海协会对应的样品编码
                    sampleNo = synchronizedata.getSampleId();

                    /**获取所有混凝土 批检配置信息*/
                    List<CheckBatchConfig> batchConfigList = checkBatchConfigMapper.getList(new CheckBatchConfig().setIsDel(0).setProjectCategory(MaterialsEnum.CONCRETE.getCode()));

                    //查询 试验项目材料规格判定配置
                    List<TestProjectSpecConfig> testProjectSpecConfigList = testProjectSpecConfigMapper.getList(new TestProjectSpecConfig().setTestProjectType(MaterialsEnum.CONCRETE.getTestProjectType()));


                    for (ExperimentDetail detail : experimentDetailList) {
                        //判断试验项目是否已做完！
                        if (!concrete(detail, sampleNo)) {
                            continue;
                        }

                        JSONObject objJson = detail.getObjJson();
                        log.info("同步新增混凝土试验项目开始，品控台账id：【{}】，台账编号；【{}】,试验项目：【{}】", experiment.getId(), experiment.getExperimentNo(), detail.getTestProjectCode());
                        /**保存/完成台账混凝土 试验结果 同步至上海协会*/
                        concreteLaboratoryFactoryService.processUpload(objJson, sampleNo, experiment, batchConfigList, testProjectSpecConfigList, detail);
                        log.info("同步新增混凝土试验项目结束，品控台账id：【{}】，台账编号；【{}】,试验项目：【{}】", experiment.getId(), experiment.getExperimentNo(), detail.getTestProjectCode());
                    }


                    //品控对应状态为 3 已完成 则更新协会状态
                    if (experiment.getExperimentStatus() != null && "3".equals(experiment.getExperimentStatus().toString())) {
                        //更新协会委托状态
                        String sampleNo1 = synchronizedata.getSampleId();

                        Map<String, Object> wtSampleList = wtSampleMapper.findWTSampleList(sampleNo1);
                        if (wtSampleList == null) {
                            log.error("保存协会数据有误 样品id ：" + sampleNo1);
                            throw new RuntimeException("保存协会数据有误 样品id ：" + sampleNo1);
                        }
                        StringBuilder status = new StringBuilder();
                        if (wtSampleList.get("Status") != null) {
                            for (String s : wtSampleList.get("Status").toString().split(";")) {
                                status.append("1" + ";");
                            }
                        }
                        //更新为已完成
                        wtSampleMapper.updateWTSampleList(sampleNo1, status.toString(), "1", experiment.getConclusion());

                        //修改协会对应关系
                        synchronizedata.setFinistStatus("1");
                        shxhSynchronizedataMapper.updateByPrimaryKeySelective(synchronizedata);

                    }
                    String reportNo = "";
                    for (ExperimentDetail detail : experimentDetailList) {
                        //抗压强度
                        if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KYQD.getCode())) {
                            reportNo = ReportIdEnum.CONCRETE_HKY.getNo();
                        } else if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KSDJ.getCode())) {
                            reportNo = ReportIdEnum.CONCRETE_HKS.getNo();
                        } else if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KZQD.getCode())) {
                            reportNo = ReportIdEnum.CONCRETE_HKZ.getNo();
                        }
                    }
                    //查询协会是否存在实验台帐报表信息，不存在新增
                    PrintReport printReport;
                    if (StringUtils.isNotEmpty(synchronizedata.getConsignId())) {
                        printReport = printReportMapper.queryByConSignID(synchronizedata.getConsignId());
                        if (printReport == null && StringUtils.isNotEmpty(reportNo)) {
                            Map<String, Object> wtSampleList = wtSampleMapper.findWTSampleList(synchronizedata.getSampleId());
                            if (wtSampleList != null) {
                                //新增Print_Report表
                                String reportId = "";
                                Integer currentSN;
                                /**查询最新一条数据**/
                                printReportSerialNumber = printReportMapper.queryReportSerialNumberByItemID(wtSampleList.get("ItemID").toString());
                                if (printReportSerialNumber == null) {
                                    printReportSerialNumber = new PrintReportSerialNumber();
                                    printReportSerialNumber.setCurrentSN(0);
                                    printReportSerialNumber.setItemID((Integer) wtSampleList.get("ItemID"));
                                    printReportSerialNumber.setCurrentYear(DateHelper.getYear());
                                    printReportSerialNumber.setPreName(reportNo);
                                    reportId = reportNo + DateHelper.getYear() + "00001";
                                } else {
                                    currentSN = printReportSerialNumber.getCurrentSN();
                                    int maxId = currentSN + 1;
                                    String currentNumber = String.format("%05d", maxId);
                                    printReportSerialNumber.setCurrentSN(maxId);
                                    isUpdateSn = true;
                                    reportId = reportNo + DateHelper.getYear() + currentNumber;
                                }
                                if (wtSampleList != null) {
                                    report.setKindID(wtSampleList.get("KindID").toString());
                                    report.setItemID(wtSampleList.get("ItemID").toString());
                                    report.setConSignID(synchronizedata.getConsignId());
                                    report.setReportID(reportId);
                                    report.setImportId(synchronizedata.getImportId());
                                }
                            }
                        }
                    }

                } else {
                    //原材料
                    //查询是否同步进料
                    List<ShxhSynchronizedata> list = shxhSynchronizedataMapper.getList(new ShxhSynchronizedata().setExperimentId(experiment.getId()));

                    if (list.isEmpty() || list.get(0).getSampleNo() == null || list.get(0).getImportId() == null || list.get(0).getConsignId() == null
                            || list.get(0).getSampleId() == null) {
                        log.info("同步协会生成进料/台账/取样可能未成功！... 台账id：" + experiment.getId());
                        return;
                    }
                    //查询协会进料id
                    ShxhSynchronizedata synchronizedata1 = list.get(0);

                    //上海协会对应的样品编码
                    sampleNo = synchronizedata1.getSampleId();

                    //根据进料id查询进料数据
                    List<String> stringList = new ArrayList<>();
                    stringList.add(synchronizedata1.getImportId());
                    List<ImportList> mapList = importListMapper.findImportListById(stringList);

                    if (mapList.isEmpty() || StringUtils.isBlank(mapList.get(0).getSampleID())) {
                        log.error("根据进料id未查询到进料数据/进料规格为空！进料id : " + synchronizedata1.getImportId());
                        throw new RuntimeException("根据进料id未查询到进料数据/进料规格为空！进料id : " + synchronizedata1.getImportId());
                    }
                    String samId = mapList.get(0).getSampleID();

                    log.info("同步新增原材料试验项目开始，品控台账id：【{}】，台账编号；【{}】", experiment.getId(), experiment.getExperimentNo());
                    /**上传到协会*/
                    materialLaboratoryFactoryService.processUpload(sampleNo, experimentDetailList, experiment, samId);
                    log.info("同步新增原材料试验项目结束，品控台账id：【{}】，台账编号；【{}】", experiment.getId(), experiment.getExperimentNo());

                    //品控对应状态为 3 已完成 则更新协会状态
                    if (experiment.getExperimentStatus() != null && "3".equals(experiment.getExperimentStatus().toString())) {
                        //更新协会委托状态
                        String sampleNo1 = synchronizedata1.getSampleNo();

                        Map<String, Object> wtSampleList = wtSampleMapper.findWTSampleList(sampleNo1);
                        if (wtSampleList == null) {
                            log.error("保存协会数据有误 样品id ：" + sampleNo1);
                            throw new RuntimeException("保存协会数据有误 样品id ：" + sampleNo1);
                        }
                        String status = "";
                        if (wtSampleList.get("Status") != null) {
                            for (String s : wtSampleList.get("Status").toString().split(";")) {
                                status += "1" + ";";
                            }
                        }
                        //更新为已完成
                        wtSampleMapper.updateWTSampleList(sampleNo1, status, "1", experiment.getConclusion());
                        //修改协会对应关系
                        synchronizedata1.setFinistStatus("1");
                        shxhSynchronizedataMapper.updateByPrimaryKeySelective(synchronizedata1);

                    }
                    String reportId = "";

                    //查询协会是否存在实验台帐报表信息，不存在新增
                    PrintReport printReport;
                    if (StringUtils.isNotEmpty(synchronizedata1.getConsignId())) {
                        printReport = printReportMapper.queryByConSignID(synchronizedata1.getConsignId());
                        String reportNo = ReportIdEnum.selectByCode(experiment.getExperimentType()).getNo();

                        report.setConSignID(synchronizedata1.getConsignId());
                        report.setImportId(synchronizedata1.getImportId());
                        report.setKindID(mapList.get(0).getKindId());
                        report.setItemID(mapList.get(0).getItemId());

                        if (printReport == null && StringUtils.isNotEmpty(reportNo)) {
                            Integer currentSN;
                            /**查询最新一条数据**/
                            printReportSerialNumber = printReportMapper.queryReportSerialNumberByItemID(report.getItemID());
                            if (printReportSerialNumber == null) {
                                printReportSerialNumber = new PrintReportSerialNumber();
                                printReportSerialNumber.setCurrentSN(0);
                                printReportSerialNumber.setItemID(Integer.valueOf(report.getItemID()));
                                printReportSerialNumber.setCurrentYear(DateHelper.getYear());
                                printReportSerialNumber.setPreName(reportNo);
                                reportId = reportNo + DateHelper.getYear() + "00001";
                            } else {
                                currentSN = printReportSerialNumber.getCurrentSN();
                                int maxId = currentSN + 1;
                                String currentNumber = String.format("%05d", maxId);
                                printReportSerialNumber.setCurrentSN(maxId);
                                isUpdateSn = true;
                                reportId = reportNo + DateHelper.getYear() + currentNumber;
                            }
                            report.setReportID(reportId);
                        } else {
                            report.setReportID(printReport.getReportID());
                        }
                    }
                }

                //更新协会入场时间
                if (!MaterialsEnum.CONCRETE.getCode().equals(experiment.getExperimentType()) && experiment.getAdmissionTime() != null) {
                    importListMapper.updateImportDateListReportID(experiment.getAdmissionTime(), report.getImportId());
                }

                //** 水泥试验，如果做了凝结时间、安定性、标准稠度、就往printreport表及有关表插入条数据**/
                boolean isSnFlag = MaterialsEnum.CEMENT.getCode().equals(experiment.getExperimentType()) && isSnTestPojector(experimentDetailList);
                /**只有已完成的试验台账才生成**/
                if (ObjectUtil.isNotEmpty(report.getReportID()) && ExperimentStatusEnum.FINISH.getCode().equals(experiment.getExperimentStatus())) {
                    /**插入协会报表表**/
                    savePrintReport(report, experiment, jcrq, isUpdateSn, printReportSerialNumber);

                    //更新协会wt 报告编号
                    wtConsignMapper.updateWtConsign(report.getReportID(), report.getConSignID(), experiment.getConclusion());

                    //更新协会wt 报告编号
                    importListMapper.updateImportListReportID(report.getReportID(), report.getImportId());

                    List<String> stringList = new ArrayList<>();
                    stringList.add(val);

                    UploadLaboratoryEntity UploadLaboratoryEntity = new UploadLaboratoryEntity().setExptId(experiment.getId()).setExperimentId(stringList);

                    //下载协会报告等信息
                    downloadLaboratory.downloadReportLaboratory(UploadLaboratoryEntity);

                    log.info("开始操作协会【print_examrecord】表数据");
                    //保存打印记录表
                    PrintExamRecord printExamRecordOld = printReportMapper.queryBySampleID(sampleNo, report.getConSignID());
                    PrintExamRecord printExamRecord = new PrintExamRecord();
                    printExamRecord.setKindID(report.getKindID());
                    printExamRecord.setItemID(report.getItemID());
                    printExamRecord.setConSignID(report.getConSignID());
                    printExamRecord.setSampleID(sampleNo);
                    printExamRecord.setExamPerson(experiment.getSocietyUserName());
                    printExamRecord.setExamTime(jcrq);
                    printExamRecord.setPrintStatus("0");
                    printExamRecord.setReportApproval("1");
                    printExamRecord.setReportApprovalLoginType("0");
                    printExamRecord.setReportApprovalTime(jcrq);
                    printExamRecord.setUploadFlag(UploadFlagUtils.CtoGB_Num(sampleNo, "z", new Date(), null));
                    if (printExamRecordOld == null) {
                        printReportMapper.insertPrintExamRecord(printExamRecord);
                    } /*李总确认目前只新增，不修改else {
                        printExamRecord.setID(printExamRecordOld.getID());
                        printReportMapper.updatePrintExamRecord(printExamRecord);
                    }*/
                    log.info("操作协会【print_examrecord】表成功，入参：【{}】", JsonUtils.getJson(printExamRecord));
                } else if (isSnFlag) {
                    /**插入协会报表表**/
                    savePrintReport(report, experiment, jcrq, isUpdateSn, printReportSerialNumber);

                    //更新协会wt 报告编号
                    wtConsignMapper.updateWtConsign(report.getReportID(), report.getConSignID(), experiment.getConclusion());

                    //更新协会wt 报告编号
                    importListMapper.updateImportListReportID(report.getReportID(), report.getImportId());


                    List<String> stringList = new ArrayList<>();
                    stringList.add(val);

                    UploadLaboratoryEntity UploadLaboratoryEntity = new UploadLaboratoryEntity().setExptId(experiment.getId()).setExperimentId(stringList);

                    //下载协会报告等信息
                    downloadLaboratory.downloadReportLaboratory(UploadLaboratoryEntity);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("保存/完成台账试验结果上传协会失败" + e.getMessage());
        }
    }


    //混凝土
    private boolean concrete(ExperimentDetail detail, String sampleNo) {
        JSONObject objJson = detail.getObjJson();
        Map<String, Object> wtSampleList = wtSampleMapper.findWTSampleList(sampleNo);
        //抗压强度
        if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KYQD.getCode())) {
            ConcreteKyqd concreteKyqd = objJson.toJavaObject(ConcreteKyqd.class);
            if (concreteKyqd != null && StringUtils.isNotBlank(concreteKyqd.getPjz7d()) && StringUtils.isNotBlank(concreteKyqd.getPjz28d())
                    && !"0.00".equals(concreteKyqd.getPjz7d()) && !"0.00".equals(concreteKyqd.getPjz28d())) {
                if (wtSampleList != null && wtSampleList.get("Sample_Status") != null && "1".equals(wtSampleList.get("Sample_Status").toString())) {
                } else {
                    wtSampleMapper.updateWTSample(sampleNo, "2");
                }

                return true;
            }
            //抗渗等级
        } else if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KSDJ.getCode())) {

            ConcreteKsdj concreteKsdj = objJson.toJavaObject(ConcreteKsdj.class);
            if (concreteKsdj != null && !concreteKsdj.getKsInfo().isEmpty() && StringUtils.isNotBlank(concreteKsdj.getKsInfo().get(0).getSyyl())) {
                if (wtSampleList != null && wtSampleList.get("Sample_Status") != null && "1".equals(wtSampleList.get("Sample_Status").toString())) {
                } else {
                    wtSampleMapper.updateWTSample(sampleNo, "2");
                }
            }
            return true;
            //抗折强度
        } else if (detail.getTestProjectCode().equals(TestProjectEnum.CONCRETE_PARAM_KZQD.getCode())) {
            ConcreteKzqd concreteKzqd = objJson.toJavaObject(ConcreteKzqd.class);
            if (concreteKzqd != null && StringUtils.isNotBlank(concreteKzqd.getPjz())
                    && !"0.00".equals(concreteKzqd.getPjz())) {
                if (wtSampleList != null && wtSampleList.get("Sample_Status") != null && "1".equals(wtSampleList.get("Sample_Status").toString())) {
                } else {
                    wtSampleMapper.updateWTSample(sampleNo, "2");
                }
            }

            return true;
        }

        return false;
    }

    private void savePrintReport(PrintReport report, Experiment experiment, Date jcrq, boolean isUpdateSn, PrintReportSerialNumber printReportSerialNumber) {
        log.info("开始操作协会【Print_Report】表数据");
        /** 所有的原材料报告，报告日期为最后一天检测日期 **/
        Date reportDate = experiment.getExperimentType() == 7 ? new Date() : jcrq;
        if (isUpdateSn) {
            printReportMapper.updateReportSerialNumber(printReportSerialNumber);
        } else {
            printReportMapper.insertReportSerialNumber(printReportSerialNumber);
        }
        /**暂定验证码生成规则为 itemId+1442+四位随机数+四个空格 **/
        report.setIdentifyingCode(report.getItemID() + "1442" + new Random().nextInt(9000) + "    ");
        report.setReportCreateDate(jcrq);
        report.setReportAuditTime(jcrq);
        report.setReportCreateTime(new Date());
        report.setReportCreatePerson(experiment.getSocietyUserName());
        report.setProjectID("1");
        report.setReportAuditId("0");
        report.setReportAudit("1");
        report.setReportAuditLoginType("0");
        report.setReportSendOut("0");
        report.setPrintStatus("0");
        report.setGetReportType("自取");
        report.setUploadFlag(UploadFlagUtils.CtoGB_Num(report.getConSignID(), "z", new Date(), null));
        PrintReport printReportOld = printReportMapper.queryByConSignID(report.getConSignID());
        if (printReportOld == null) {
            printReportMapper.insertPrintReport(report);
            experimentMapper.updateByPrimaryKeySelective(new Experiment().setId(experiment.getId()).setReportNo(report.getReportID()).setReportDate(reportDate));
        } /*李总确认目前只新增，不修改
        else {
            report.setID(printReportOld.getID());
            printReportMapper.updatePrintReport(report);
        }*/
        log.info("操作协会【Print_Report】表成功，入参：【{}】", JsonUtils.getJson(report));
    }

    //判断对应实验项目是否存在平均值
    private boolean isSnTestPojector(List<ExperimentDetail> experimentDetailList) {
        int count = 0;
        for (ExperimentDetail detail : experimentDetailList) {
            JSONObject objJson = detail.getObjJson();
            //凝结时间
            if (detail.getTestProjectCode().equals(CementEnum.NJSJ.getTestProjectType())) {
                CementNjsj cementNjsj = JsonUtils.getObject(objJson, CementNjsj.class);
                CementNjsj.Jgjs jgjs = cementNjsj.getJgjs();
                if (NullUtils.isNull(jgjs.getCnsj()) || NullUtils.isNull(jgjs.getZnsj())) {
                    return false;
                } else {
                    count++;
                }
            }
            //安定性
            if (detail.getTestProjectCode().equals(CementEnum.ADX.getTestProjectType())) {
                CementAdx cementAdx = objJson.toJavaObject(CementAdx.class);
                CementAdx.Lsf lsf = cementAdx.getLsf();
                CementAdx.Sbf sbf = cementAdx.getSbf();
                if (NullUtils.isNull(sbf.getJl()) && NullUtils.isNull(lsf.getPjz())) {
                    return false;
                } else {
                    count++;
                }
            }
            //标准稠度
            if (detail.getTestProjectCode().equals(CementEnum.BZCD.getTestProjectType())) {
                CementBzcd cementBzcd = objJson.toJavaObject(CementBzcd.class);
                if (NullUtils.isNull(cementBzcd.getBzcdysl())) {
                    return false;
                } else {
                    count++;
                }
            }
            //3d抗压强度
            if (detail.getTestProjectCode().equals(CementEnum.QDCD.getTestProjectType())) {
                CementQdcd cementQdcd = JsonUtils.getObject(objJson, CementQdcd.class);
                CementQdcd.Kyqdsy kyqdsy3d = cementQdcd.getKyqdsy3d();
                if (NullUtils.isNull(kyqdsy3d.getPjz())) {
                    return false;
                } else {
                    count++;
                }
            }
        }
        if (count == 4) {
            return true;
        }
        return false;
    }
}
